<template>
  <div class="banner">
    <!-- 左侧导航栏 -->
    <!-- <div class="animated fadeIn">我是淡入效果</div> -->
    <transition
      enter-active-class="animated bounceInLeft"
      leave-active-class="animated bounceOutLeft"
    >
      <div class="banner-left" v-show="isshow"></div>
    </transition>

    <!-- 顶部定位，搜索栏 -->
    <div class="search">
      <div class="searchAdress" @click="goCity(path)">
        <span>{{path? path:'请选择地址'}}</span>
        <i class="iconfont icon-xiajiantou"></i>
      </div>
      <label class="searchInput">
        <span class="iconfont icon-fangdajing fdj"></span>
        <input type="text" placeholder="探索未知世界" />
      </label>
      <div class="fenlei" @click="showleft">
        <i class="iconfont icon-fenlei"></i>
      </div>
    </div>
    <!-- hot -->
    <div class="hot">
      <span>热搜</span>
      <div class="hotPath">
        <a href="#">北京</a>
        <a href="#">上海</a>
        <a href="#">杭州</a>
        <a href="#">深圳</a>
      </div>
    </div>

    <!-- swiper 栏 -->
    <div class="swiper">
      <swiper ref="mySwiper" :options="swiperOptions" class="swiper-item">
        <swiper-slide v-for="(item,index) in swpierImgs" :key='index'>
          <img :src="item.img"/>
        </swiper-slide>
        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  props: {},
  data() {
    return {
      path:'',
      swiperOptions: {
        pagination: {
          el: ".swiper-pagination",
          bulletElement: "li",
          clickable: true
        },
        autoplay: {
          delay: 2000,
          //当用户滑动图片后继续自动轮播
          disableOnInteraction: false
        },
        loop: true
      },
      isshow: false,
      swpierImgs:[
        {img:require('../../assets/images/swiper1.jpg')},
        {img:require('../../assets/images/swiper2.jpg')},
        {img:require('../../assets/images/swiper3.jpg')},
        {img:require('../../assets/images/swiper4.jpg')},
        {img:require('../../assets/images/swiper5.jpg')},
        {img:require('../../assets/images/swiper6.jpg')},
        {img:require('../../assets/images/swiper7.jpg')},
        {img:require('../../assets/images/swiper8.jpg')}
      ]
    };
  },
  watch: {},
  computed: {},
  methods: {
    showleft() {
      this.isshow = !this.isshow;
    },
    goCity(p){
      // console.log(p)
      this.$router.push({name:'city',params:{id:p}})
    }
  },
  created() {},
  mounted() {
    this.path = localStorage.getItem('selectAdress')
    if(!this.path){
      this.path = this.$store.state.City.selectedCity
    }
  },
  activated(){
    this.path = this.$store.state.City.selectedCity
  }
};
</script>
<style lang="less" scoped>
.banner {
  position: relative;
  font-size: 15/37.5rem;
  position: relative;
  width: 100%;
  background-color: #ffdd40;
  .banner-left {
    position: fixed;
    left: 0;
    top: 0;
    width: 150/37.5rem;
    height: 100vh;
    background-color: #000;
    z-index: 999;
  }
  .search {
    display: flex;
    align-items: center;
    height: 50/37.5rem;
    .fenlei {
      margin: 0 10/37.5rem;
      i {
        font-size: 20/37.5rem;
      }
    }
    .searchInput {
      flex: 1;
      padding: 0 10/37.5rem;
      border-radius: 30/37.5rem;
      background-color: #fff;
      display: flex;
      align-items: center;
      .fdj {
        font-size: 20/37.5rem;
      }
      input {
        width: 100%;
        height: 30/37.5rem;
        border: 0;
        outline: none;
        background-color: rgba(0, 0, 0, 0); // 透明背景
      }
    }
    .searchAdress {
      display: flex;
      align-items: center;
      padding: 10/37.5rem 10/37.5rem;
      // font-weight: 700;
      i {
        margin-left: 10/37.5rem;
      }
    }
  }
  .hot {
    //  box-sizing: border-box;
    width: 100%;
    padding: 10/37.5rem 0;
    display: flex;
    align-items: center;
    span {
      font-size: 10/37.5rem;
      padding: 0 10/37.5rem;
    }
    .hotPath {
      flex: 1;
      display: flex;
      justify-content: space-around;
      align-items: center;
      a {
        padding: 0 20/37.5rem;
        background-color: #ffeea0;
        text-decoration: none;
        border-radius: 20/37.5rem;
      }
    }
  }
  .swiper {
    width: 95%;
    margin: 0 auto;
    height: 155/37.5rem;
    .swiper-pagination /deep/.swiper-pagination-bullet {
      width: 5/37.5rem;
      height: 5/37.5rem;
      background-color: #dddddd;
      opacity: 1;
    }
    .swiper-pagination /deep/ .swiper-pagination-bullet-active {
      width: 11/37.5rem;
      height: 5/37.5rem;
      border-radius: 5/37.5rem;
      background-color: #ffdd40;
    }
    .swiper-item {
      border-radius: 15/37.5rem;
      overflow: hidden;
      img {
        width: 100%;
        height: 155/37.5rem;
      }
    }
  }
  &::after {
    content: "";
    display: block;
    width: 100%;
    height: 50/37.5rem;
    background-color: #fff;
    position: absolute;
    left: 0;
    bottom: 0;
  }
}
</style>